package com.devicemantra.coordinate.dao;

import org.hibernate.SessionFactory;
import org.hibernate.Session;
import org.hibernate.cfg.Configuration;
 
public class HibernateUtil {
 
  private static SessionFactory sessionFactory;
 
  public static SessionFactory getSessionFactory() {
    if (sessionFactory == null) {
      initSessionFactory();
    }
    return sessionFactory;
  }
 
  private static synchronized void initSessionFactory() {
    sessionFactory = new Configuration().configure().buildSessionFactory();
  }
 
  public static Session getSession() {
    return getSessionFactory().openSession();
  }
 
  
}